//
//  TCLYMineModel.m
//  YuErmuYing
//
//  Created by LYang on 16/8/11.
//  Copyright © 2016年 Tiancheng. All rights reserved.
//

#import "TCLYMineModel.h"
#import "HttpRequest.h"
@implementation TCLYMineModel
-(void)loadCellImage{
    self.cellImageArr = [NSMutableArray arrayWithObjects:@"wallet", @"reservation" , @"post", @"task", @"signIn", @"setting", @"LYAbout",nil];
}

-(void)loadCellLabelText{
    self.cellLabelTextArr = [NSMutableArray arrayWithObjects:@"钱包", @"预定", @"帖子", @"任务", @"签到", @"设置",@"关于",nil];
    self.taskNameArr = [NSMutableArray arrayWithObjects:@"每日签到", @"邀请宝妈", @"每日回答2次", @"每日提问", @"每日分享朋友圈", @"中奖评论", @"充值", nil];
    self.rewardArr = [NSMutableArray arrayWithObjects:@"5积分", @"5积分", @"5积分", @"5积分", @"5积分", @"5积分", @"10积分", nil];
    self.taskArr = [NSMutableArray arrayWithObjects:@"去签到", @"去邀请", @"去回答", @"去提问", @"去分享", @"去评论", @"去充值", nil];
    self.settingArr = [NSMutableArray arrayWithObjects:@"资料", @"修改密码", @"收货地址", nil];
    
}
-(void)loadMineParameters:(NSDictionary *)parameters{
    NSString * urlStr = @"http://112.74.114.1/Parenting/index.php/api/user/user";
    HttpRequest * httpRequest = [HttpRequest sharedInstance];
    [httpRequest postWithURLString:urlStr parameters:parameters success:^(id responseObject) {
        id json = [NSJSONSerialization JSONObjectWithData:responseObject options:0 error:nil];
        self.mineDic = json[@"data"];
        NSLog(@"%@",json);
        [[NSNotificationCenter defaultCenter] postNotificationName:@"loadMineSucceed" object:self];
    } failure:^(NSError *error) {
        NSLog(@"%@",error);
    }];
}

//加载预约的接口
-(void)loadReservationParameters:(NSDictionary *) parameters{
    NSString * urlStr = @"http://112.74.114.1/parenting/index.php/api/appoint/appo_record";
    HttpRequest * httpRequest = [HttpRequest sharedInstance];
    [httpRequest postWithURLString:urlStr parameters:parameters success:^(id responseObject) {
        id json = [NSJSONSerialization JSONObjectWithData:responseObject options:0 error:nil];
        self.reservationArr = json[@"data"];
        NSLog(@"%@",json);
        [[NSNotificationCenter defaultCenter] postNotificationName:@"loadReservationSucceed" object:self];
    } failure:^(NSError *error) {
        NSLog(@"%@",error);
    }];
}
//加载帖子的接口
-(void)loadTieZiParameters:(NSDictionary *)parameters{
    NSString * urlStr = @"http://112.74.114.1/Parenting/index.php/api/note/note_person";
    HttpRequest * httpRequest = [HttpRequest sharedInstance];
    [httpRequest postWithURLString:urlStr parameters:parameters success:^(id responseObject) {
        id json = [NSJSONSerialization JSONObjectWithData:responseObject options:0 error:nil];
        self.TieZiArr = json[@"data"];
        NSLog(@"帖子%@",json);
        [[NSNotificationCenter defaultCenter] postNotificationName:@"loadTieZiSucceed" object:self];
    } failure:^(NSError *error) {
        NSLog(@"加载帖子:%@",error);
    }];
}
//取消服务的接口
-(void)cancelReservationParameters:(NSDictionary *)parameters{
    NSString * urlStr = @"http://112.74.114.1/Parenting/index.php/api/appoint/appo_appo";
    HttpRequest * httpRequest = [HttpRequest sharedInstance];
    [httpRequest postWithURLString:urlStr parameters:parameters success:^(id responseObject) {
        id json = [NSJSONSerialization JSONObjectWithData:responseObject options:0 error:nil];
        NSLog(@"%@",json);
        if ([json[@"data"] isEqual:@1]) {
            self.reservationArr = nil;
            [[NSNotificationCenter defaultCenter] postNotificationName:@"cancelSucced" object:self];
        }else{
            if ([json[@"msg"] isEqual:@400]) {
                [[NSNotificationCenter defaultCenter] postNotificationName:@"cancelError" object:self];
                return ;
            }
            self.reservationArr = json[@"data"];
            [[NSNotificationCenter defaultCenter] postNotificationName:@"cancelSucced" object:self];
        }

    } failure:^(NSError *error) {
        NSLog(@":%@",error);
    }];
}
//提醒服务的接口
-(void)remindReservationParameters:(NSDictionary *) parameters{
    NSString * urlStr = @"http://112.74.114.1/Parenting/index.php/api/appoint/appo_remind";
    HttpRequest * httpRequest = [HttpRequest sharedInstance];
    [httpRequest postWithURLString:urlStr parameters:parameters success:^(id responseObject) {
        id json = [NSJSONSerialization JSONObjectWithData:responseObject options:0 error:nil];
        NSLog(@"%@",json);
    } failure:^(NSError *error) {
        NSLog(@":%@",error);
    }];
}
//编辑帖子的接口
-(void)editorTieZiParameters:(NSDictionary *)parameters{
    NSString * urlStr = @"http://112.74.114.1/Parenting/index.php/api/note/note_edit";
    HttpRequest * httpRequest = [HttpRequest sharedInstance];
    [httpRequest postWithURLString:urlStr parameters:parameters success:^(id responseObject) {
        id json = [NSJSONSerialization JSONObjectWithData:responseObject options:0 error:nil];
        NSLog(@"编辑哦%@",json);
    } failure:^(NSError *error) {
        NSLog(@":%@",error);
    }];
}
//删除帖子的接口
-(void)deleteTieZiParameters:(NSDictionary *)parameters{
    NSString * urlStr = @"http://112.74.114.1/Parenting/index.php/api/note/note_del";
    HttpRequest * httpRequest = [HttpRequest sharedInstance];
    [httpRequest postWithURLString:urlStr parameters:parameters success:^(id responseObject) {
        id json = [NSJSONSerialization JSONObjectWithData:responseObject options:0 error:nil];
        if ([json[@"data"] isEqual:@1]) {
            self.TieZiArr = nil;
        }else{
            self.TieZiArr = json[@"data"];
        }
        NSLog(@"%@",json);
        [[NSNotificationCenter defaultCenter] postNotificationName:@"deleteTieZiSucced" object:self];
    } failure:^(NSError *error) {
        NSLog(@":%@",error);
    }];
}
//加载签到的接口
-(void)loadSigninParameters:(NSDictionary *)parameters{
    NSString * urlStr = @"http://112.74.114.1/Parenting/index.php/api/sign/index";
    HttpRequest * httpRequest = [HttpRequest sharedInstance];
    [httpRequest postWithURLString:urlStr parameters:parameters success:^(id responseObject) {
        id json = [NSJSONSerialization JSONObjectWithData:responseObject options:0 error:nil];
        self.signinArr = json[@"data"];
        self.signinDic = json[@"msg"];
        NSLog(@"%@",json);
        [[NSNotificationCenter defaultCenter] postNotificationName:@"loadSigninSucceed" object:self];
    } failure:^(NSError *error) {
        NSLog(@"%@",error);
    }];
}
//签到的接口
-(void)loadSignParameters:(NSDictionary *)parameters{
    NSString * urlStr = @"http://112.74.114.1/Parenting/index.php/api/sign/show";
    HttpRequest * httpRequest = [HttpRequest sharedInstance];
    [httpRequest postWithURLString:urlStr parameters:parameters success:^(id responseObject) {
        id json = [NSJSONSerialization JSONObjectWithData:responseObject options:0 error:nil];
        NSLog(@"%@",json);
    } failure:^(NSError *error) {
        NSLog(@"%@",error);
    }];
}
//加载消息的接口
-(void)loadNewsParameters:(NSDictionary *)parameters{

    NSString * urlStr = @"http://112.74.114.1/Parenting/index.php/api/message/message";
    HttpRequest * httpRequest = [HttpRequest sharedInstance];
    [httpRequest postWithURLString:urlStr parameters:parameters success:^(id responseObject) {
        id json = [NSJSONSerialization JSONObjectWithData:responseObject options:0 error:nil];
        self.newsArr = json[@"data"];
        [[NSNotificationCenter defaultCenter] postNotificationName:@"loadNewsSucceed" object:self];
        NSLog(@"%@",self.newsArr);
    } failure:^(NSError *error) {
        NSLog(@"%@",error);
    }];
}
//删除消息的接口
-(void)deleteNewsParameter:(NSDictionary *)parameters{
    NSString * urlStr = @"http://112.74.114.1/Parenting/index.php/api/message/msgdel";
    HttpRequest * httpRequest = [HttpRequest sharedInstance];
    [httpRequest postWithURLString:urlStr parameters:parameters success:^(id responseObject) {
        id json = [NSJSONSerialization JSONObjectWithData:responseObject options:0 error:nil];
        if (json[[@"data" isEqual:@1]]) {
            self.newsArr = nil;
        }else{
           self.newsArr = json[@"data"]; 
        }
        [[NSNotificationCenter defaultCenter] postNotificationName:@"deleteNewsSucceed" object:self];
        NSLog(@"%@",json);
    } failure:^(NSError *error) {
        NSLog(@"%@",error);
    }];
}
//x显示个人信息的接口
-(void)loadInformationParameter:(NSDictionary *)parameters{
    NSString * urlStr = @"http://112.74.114.1/Parenting/index.php/api/user/info";
    HttpRequest * httpRequest = [HttpRequest sharedInstance];
    [httpRequest postWithURLString:urlStr parameters:parameters success:^(id responseObject) {
        id json = [NSJSONSerialization JSONObjectWithData:responseObject options:0 error:nil];
        self.informationDic = json[@"data"];
        [[NSNotificationCenter defaultCenter] postNotificationName:@"loadInformation" object:self];
        NSLog(@"%@",json);
    } failure:^(NSError *error) {
        NSLog(@"%@",error);
    }];
}
//修改密码的接口
-(void)updatePasswordParameter:(NSDictionary *)parameters{
    NSString * urlStr = @"http://112.74.114.1/Parenting/index.php/api/user/password";
    HttpRequest * httpRequest = [HttpRequest sharedInstance];
    [httpRequest postWithURLString:urlStr parameters:parameters success:^(id responseObject) {
        id json = [NSJSONSerialization JSONObjectWithData:responseObject options:0 error:nil];
        self.updatePasswordSucceedStr = json[@"msg"];
        [[NSNotificationCenter defaultCenter] postNotificationName:@"updatePasswordSucceed" object:self];
        NSLog(@"%@",json);
    } failure:^(NSError *error) {
        NSLog(@"%@",error);
    }];
}
//设置默认地址的接口
-(void)defaultAddressParameter:(NSDictionary *)parameters{
    NSString * urlStr = @"http://112.74.114.1/Parenting/index.php/api/address/dfault";
    HttpRequest * httpRequest = [HttpRequest sharedInstance];
    [httpRequest postWithURLString:urlStr parameters:parameters success:^(id responseObject) {
        id json = [NSJSONSerialization JSONObjectWithData:responseObject options:0 error:nil];
        NSLog(@"%@",json);
    } failure:^(NSError *error) {
        NSLog(@"%@",error);
    }];
}
//删除地址的接口
-(void)deleteAddressParameter:(NSDictionary *)parameters{
    NSString * urlStr = @"http://112.74.114.1/Parenting/index.php/api/address/delete";
    HttpRequest * httpRequest = [HttpRequest sharedInstance];
    [httpRequest postWithURLString:urlStr parameters:parameters success:^(id responseObject) {
        id json = [NSJSONSerialization JSONObjectWithData:responseObject options:0 error:nil];
        if (json[[@"data" isEqual:@1]]) {
            self.addressArr = nil;
        }else{
            self.addressArr = json[@"data"];
        }
        [[NSNotificationCenter defaultCenter] postNotificationName:@"deleteAddressSucceed" object:self];
        NSLog(@"%@",json);
    } failure:^(NSError *error) {
        NSLog(@"%@",error);
    }];
}
//加载地址列表的接口
-(void)loadAddressParameter:(NSDictionary *)parameters{
    NSString * urlStr = @"http://112.74.114.1/Parenting/index.php/api/address/addresslist";
    HttpRequest * httpRequest = [HttpRequest sharedInstance];
    [httpRequest postWithURLString:urlStr parameters:parameters success:^(id responseObject) {
        id json = [NSJSONSerialization JSONObjectWithData:responseObject options:0 error:nil];
        self.addressArr = json[@"data"];
        [[NSNotificationCenter defaultCenter] postNotificationName:@"loadAddressSucceed" object:self];
        NSLog(@"%@",json);
    } failure:^(NSError *error) {
        NSLog(@"%@",error);
    }];
}
//修改地址的接口
-(void)updateAddressParameter:(NSDictionary *)parameters{
    NSString * urlStr = @"http://112.74.114.1/Parenting/index.php/api/address/update";
    HttpRequest * httpRequest = [HttpRequest sharedInstance];
    [httpRequest postWithURLString:urlStr parameters:parameters success:^(id responseObject) {
        id json = [NSJSONSerialization JSONObjectWithData:responseObject options:0 error:nil];
        NSLog(@"%@",json);
    } failure:^(NSError *error) {
        NSLog(@"%@",error);
    }];
}
//添加
-(void)addAddressParameter:(NSDictionary *)parameters{
    NSString * urlStr = @"http://112.74.114.1/Parenting/index.php/api/address/add";
    HttpRequest * httpRequest = [HttpRequest sharedInstance];
    [httpRequest postWithURLString:urlStr parameters:parameters success:^(id responseObject) {
        id json = [NSJSONSerialization JSONObjectWithData:responseObject options:0 error:nil];
        NSLog(@"%@",json);
    } failure:^(NSError *error) {
        NSLog(@"%@",error);
    }];
}
//提现
-(void)withdrawalParameter:(NSDictionary *)parameter{
    NSString * urlStr = @"http://112.74.114.1/Parenting/index.php/api/cash/index";
    HttpRequest * httpRequest = [HttpRequest sharedInstance];
    [httpRequest postWithURLString:urlStr parameters:parameter success:^(id responseObject) {
        id json = [NSJSONSerialization JSONObjectWithData:responseObject options:0 error:nil];
        self.withdrawalSucceed = json[@"data"];
        [[NSNotificationCenter defaultCenter] postNotificationName:@"withdrawalSucceed" object:self];
        NSLog(@"%@",json);
    } failure:^(NSError *error) {
        NSLog(@"%@",error);
    }];
}
//钱包明细的接口
-(void)walletDetailParameter:(NSDictionary *)parameter{
    NSString * urlStr = @"http://112.74.114.1/Parenting/index.php/api/cash/detail";
    HttpRequest * httpRequest = [HttpRequest sharedInstance];
    [httpRequest postWithURLString:urlStr parameters:parameter success:^(id responseObject) {
        id json = [NSJSONSerialization JSONObjectWithData:responseObject options:0 error:nil];
        NSLog(@"%@",json);
        if ([json[@"data"] isEqual:@0]) {
            self.walletDetailArr = nil;
        }else{
            self.walletDetailArr = json[@"data"];
            [[NSNotificationCenter defaultCenter] postNotificationName:@"walletDetail" object:self];        
        }
    } failure:^(NSError *error) {
        NSLog(@"%@",error);
    }];
}
//修改资料的接口（不修改头像的时候）
-(void)updateInformationParameter:(NSDictionary *) parameter{
    NSString * urlStr = @"http://112.74.114.1/Parenting/index.php/api/user/editinfo";
    HttpRequest * httpRequest = [HttpRequest sharedInstance];
    [httpRequest postWithURLString:urlStr parameters:parameter success:^(id responseObject) {
        id json = [NSJSONSerialization JSONObjectWithData:responseObject options:0 error:nil];
        self.updateInforStr = json[@"msg"];
        [[NSNotificationCenter defaultCenter]postNotificationName:@"updateInfor" object:self];
        NSLog(@"%@",json);
    } failure:^(NSError *error) {
        NSLog(@"%@",error);
    }];
}
//有消息来得时候 点击消息提醒的数量会消失
-(void)disappearNewsPromptParameter:(NSDictionary *) parameter{
    NSString * urlStr = @"http://112.74.114.1/Parenting/index.php/api/message/remind_status";
    HttpRequest * httpRequest = [HttpRequest sharedInstance];
    [httpRequest postWithURLString:urlStr parameters:parameter success:^(id responseObject) {
        id json = [NSJSONSerialization JSONObjectWithData:responseObject options:0 error:nil];
        NSLog(@"%@",json);
    } failure:^(NSError *error) {
        NSLog(@"%@",error);
    }];
}

@end
